Show:

Q audiopicker Class

jQuery plugin that allows to create or upload an audio file to the server. Works on various platforms (desktop and mobile etc) in similar way. Should be applied to element like this $('#someimg').plugin('Q/audio', options).

Constructor

Q audiopicker

(
  • [options]
)

Parameters:

  • [options] Object optional

    options is an Object that contains parameters for function

    • [url] String optional

      url is a url to post to.

    • [path="uploads"] String optional

      Can be a URL path or a function returning a URL path. It must exist on the server.

    • [subpath=""] String | Function optional

      A subpath which may be created on the server if it doesn't already exist. If this is a function, it is executed right before the request is sent.

    • [preprocess] Q.Event optional

      preprocess is a function which is triggering before file upload. Its "this" object will be a jQuery of the audiopicker element The first parameter is a callback, which should be called with an optional hash of overrides, which can include "data", "path", "subpath", "save", "url", "loader"

    • [onSuccess] Q.Event optional

      onSuccess is Q.Event which is called on successful upload. First parameter will be the server response.

    • [onError] Q.Event optional

      onError Q.Event which is called if upload failed.

    • [onFinish] Q.Event optional

      onFinish Q.Event which is called at the end, whatever the outcome.

Methods

_process

()

Process file uploading

formatRecordTime

(
  • time
)
String

Format record time elapsed

Parameters:

  • time Int

    Time elapsed in seconds

Returns:

String:

formatted string

pauseAudio Pause audio and detect promise event on mobile devices

()

pick

()

Set the audio

playAudio Play audio and detect promise event on mobile devices

()

player

()

Audio player

recorderStateChange

(
  • newState
)

Handle recorder states

Parameters:

  • newState String

    New recorder state

remove

()

Removes the Q/audio functionality from the element

start

()

Start audio creation dialog

userGesture User gesture handler for audio actions if promise != undefined (mobile devices)

(
  • action
  • promise
)

Parameters:

  • action String

    Player action (play, pause, ...)

  • promise Object

    Promise returned